package sort;

import java.util.Arrays;

public class Selective {
	public static void main(String[] args) {
		int[] arr = {9,1,6,4,2};
		
		// 1.两层for套if  2.外层元素下标j和内层元素下标i去比较  3.如果从小到大使用>,从大到小使用<
		for (int j = 0; j < arr.length - 1; j++) {
			for (int i = j + 1; i < arr.length; i++) {
				if (arr[j] > arr[i]) {
					int t = arr[j];
					arr[j] = arr[i];
					arr[i] = t;
				}
			} 
		}
		
		System.out.println(Arrays.toString(arr));
	}
}
